const { request } = require('../utils/request')

/**
 * 预约相关API
 */
const appointmentApi = {
  // 创建预约
  createAppointment(data) {
    return request({
      url: '/appointment/create',
      method: 'POST',
      data
    })
  },

  // 获取我的预约列表
  getMyAppointments() {
    return request({
      url: '/appointment/my',
      method: 'GET'
    })
  },

  // 获取预约详情
  getAppointmentById(id) {
    return request({
      url: `/appointment/${id}`,
      method: 'GET'
    })
  },

  // 取消预约
  cancelAppointment(id) {
    return request({
      url: `/appointment/cancel/${id}`,
      method: 'PUT'
    })
  },

  // 获取所有理发师排班信息
  getAllStoreManagerSchedules() {
    return request({
      url: '/appointment/schedules',
      method: 'GET'
    })
  },

  // 获取理发师在特定日期的可用时间段
  getStoreManagerAvailableHours(storeManagerId, appointmentDate) {
    return request({
      url: `/appointment/available-hours/${storeManagerId}/${appointmentDate}`,
      method: 'GET'
    })
  },

  // 根据日期获取可用理发师
  getAvailableStoreManagersByDate(appointmentDate) {
    return request({
      url: `/appointment/available-managers/${appointmentDate}`,
      method: 'GET'
    })
  },

  // 获取理发师未来可用日期
  getStoreManagerAvailableDates(storeManagerId, days = 7) {
    return request({
      url: `/appointment/available-dates/${storeManagerId}?days=${days}`,
      method: 'GET'
    })
  },

  // 获取时间段可用性信息
  getStoreManagerTimeSlotAvailability(storeManagerId, appointmentDate) {
    return request({
      url: `/appointment/time-slot-availability/${storeManagerId}/${appointmentDate}`,
      method: 'GET'
    })
  }
}

module.exports = appointmentApi 